# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>
# Contributor: @naveen521kk on Github, Naveen M K <naveen521kk@gmail.com>

_pyname=typing-extensions
_realname=typing_extensions
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.7.1
pkgrel=1
pkgdesc='Backported and Experimental Type Hints for Python 3.5+ (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://github.com/python/typing_extensions"
license=('spdx:PSF-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=(
    "${MINGW_PACKAGE_PREFIX}-python-build"
    "${MINGW_PACKAGE_PREFIX}-python-installer"
    "${MINGW_PACKAGE_PREFIX}-python-flit-core"
)
source=("https://pypi.python.org/packages/source/${_pyname:0:1}/${_pyname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('b75ddc264f0ba5615db7ba217daeb99701ad295353c45f9e95963337ceeeffb2')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
